package com.example.jdktest.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @author: dangwen
 * @createDate: 2021/7/5
 */
@Component
@Aspect
public class AspectTest {

    @Pointcut("execution(* com.example.jdktest.controller.UserController.getUser())")
    public void myPointCut() {
        System.out.println("PointCut会在什么时间打印？ ");
    }

    @Before("myPointCut()")
    public void before(JoinPoint joinPoint) {
        System.out.println("Before 会在什么时间打印？ ");
        System.out.println(joinPoint.getTarget());
    }

//    @After("myPointCut()")
//    public void after(JoinPoint joinPoint){
//        System.out.println("After 会在什么时间打印？ ");
//        System.out.println(joinPoint.getTarget());
//    }
//
//    @Around("myPointCut()")
//    public void around(ProceedingJoinPoint joinPoint){
//        System.out.println("Around 会在什么时间打印？ ");
//        try {
//            joinPoint.proceed();
//        } catch (Throwable throwable) {
//            throwable.printStackTrace();
//        }
//    }

}
